<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<?php
require 'lyb_conn.php';
session_start();
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title>编辑页面</title>
    </head>
    <body>
        <?php
        $edit="select * from n1 where id='$_GET[id]'";
        $result= mysqli_query($con, $edit);
        $result1=mysqli_fetch_array($result);
        //if($_SERVER["REQUEST_METHOD"]=="POST"){
        if(isset($_POST['tijiao'])){
        $edit1="update n1 set title='$_POST[title]',content='$_POST[content]' where id='$_POST[id]'";
        mysqli_query($con, $edit1);
        echo "<script type='text/javascript'>alert('编辑成功');</script>";
        //echo "<script type='text/javascript'>window.location.href='index.php'</script>";
        echo "<script type='text/javascript'>window.location.href='$_SESSION[url]'</script>";
        }
        ?>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]) ?>">
    <!-- 使用隐藏的input来接收编辑传过来的数据的ID，用来在保存的时候，发送给当前页面，当前页面根据ID来进行数据库的update操作 -->
    <input type="hidden" name="id" value="<?php echo $_GET[id] ?>">
    标题：<input name="title" value="<?php echo $result1[title] ?>">
    <br><br>
    内容：<textarea name="content" rows="5" cols="20"><?php echo $result1[content] ?></textarea>
    <br><br>
    <input type="submit" name="tijiao" value="保存">
    </form>  
    </body>
</html>
